<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><!--
<OBJECT ID="defenseHook" WIDTH=0 HEIGHT=0 classid="CLSID:9DDED052-128B-474B-9E19-9859D5B9D0FC">  
    <PARAM NAME="_Version" VALUE="65536">  
    <PARAM NAME="_ExtentX" VALUE="12806">  
    <PARAM NAME="_ExtentY" VALUE="1747">  
    <PARAM NAME="_StockProps" VALUE="0">  
</OBJECT> -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>HduCMS Administrator's Control Panel</title>
<#include "/view/head.html"/>
<script src="${base}/res/common/js/security.js" type="text/javascript"></script>
<script type="text/javascript">
if(top!=this) {
	top.location=this.location;
}
$(function() {
	$("#username").focus();
	$("#jvForm").validate();
});
</script>
<script type="text/javascript">
        var count = 60;
        $(function () {
            $("#btnCode").click(function () {
                var username = $("#username").val();  
                if (username == "") {
                  alert("请输入用户名！");
                  return;
                };
                if (count != 60) {return;};
                $.post("dynamicPassword.do",
                {  
                   username:username
                 },
                function(data,status){
                  //alert("Data: " + data + "\nStatus: " + status);
                  ;
                 });
                GetNumber();
            });
        })        
        function GetNumber() {
            $("#btnCode").attr("disabled", "disabled");
            $("#btnCode").val(count + "秒之后再次获取")
            count--;
            if (count > 0) {
                setTimeout(GetNumber, 1000);
            }
            else {
                $("#btnCode").val("点击获取验证码");
                $("#btnCode").attr("disabled", "");
            }
        }
</script>
<script type="text/javascript">
      var url="login.do";
      function login(){       
        var form= document.jvForm;
        encrypt();
        form.action=url;
        form.submit();
      }
      function encrypt(){
        var modulus = $("#modouls").val(), exponent = $("#exponent").val(); 
        var key = RSAUtils.getKeyPair(exponent, '', modulus);
        var username = document.getElementById("username").value;
        var usere = RSAUtils.encryptedString(key, username);
        var password;
        if($.browser.msie){
          password = document.getElementById("defenseHook").getpword();
          var temp = utf16to8(password);
          alert(temp);
          var passe = RSAUtils.encryptedString(key, temp);
          document.getElementById("username").value=usere;
          url=url+"?password="+passe;
          return;
        }
        else{
          password = document.getElementById("password").value;
          var passe = RSAUtils.encryptedString(key, password);
          document.getElementById("username").value=usere;
          document.getElementById("password").value=passe;
          return;
        }
        //var passe = RSAUtils.encryptedString(key, password);
        //document.getElementById("username").value=usere;
        //document.getElementById("password").value=passe;
      }
      
      function inputSafe(){
        if(!(document.all)){
        	return;
        }
		var str=document.getElementById("password").value;
		var caption;
		if (str.length ==1 ) {
			caption = str;
		};
		if (str.length>1) {
			caption = str.substring(str.length-1,str.length);
		};
		document.getElementById("password").blur();
		document.getElementById("defenseHook").defenseHook();
		var t=setTimeout("document.getElementById('password').focus()",200);
	}
</script>
<script type="text/javascript">
  function dofirst(){
    if($.browser.msie){
          $("#password").hide();
          document.getElementById("pw").innerHTML="<OBJECT ID=\"defenseHook\" WIDTH=152px HEIGHT=21px classid=\"CLSID:9DDED052-128B-474B-9E19-9859D5B9D0FC\"><PARAM NAME=\"_Version\" VALUE=\"65536\"><PARAM NAME=\"_ExtentX\" VALUE=\"12806\"><PARAM NAME=\"_ExtentY\" VALUE=\"1747\"><PARAM NAME=\"_StockProps\" VALUE=\"0\"></OBJECT> ";
          //alert("IE");
    }
    else{
      //document.getElementById("pw").innerHTML="<input name=\"password\" type=\"password\"id=\"password\" maxlength=\"32\" vld=\"{required:true}\" class=\"input\"/>";
      //alert("NOT IE");
    }
  }
  window.onload=dofirst;
</script>
<script type="text/javascript">
function utf16to8(str) {
     var out, i, len, c;

     out = "";
     len = str.length;
     for(i = 0; i < len; i++) {   c = str.charCodeAt(i);   if ((c >= 0x0001) && (c <= 0x007F)) {       out += str.charAt(i);   } else if (c > 0x07FF) {
      out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
      out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));
      out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
  } else {
      out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));
      out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
  }
     }
     return out;
 }
 </script>
<style type="text/css">
body{margin:0;padding:0;font-size:12px;background:url(${base}/res/jeecms/img/login/bg.jpg) top repeat-x;}
.input{width:150px;height:17px;border-top:1px solid #404040;border-left:1px solid #404040;border-right:1px solid #D4D0C8;border-bottom:1px solid #D4D0C8;}
</style>
</head>
<body>
<form name="jvForm" action="login.do" method="post">
<!--<form id="jvForm" >-->
<#if returnUrl??><input type="hidden" name="returnUrl" value="${returnUrl}"/></#if>
<#if processUrl??><input type="hidden" name="processUrl" value="${processUrl}"/></#if>
<table width="920" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="200">&nbsp;</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="423" height="280" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><img src="${base}/res/jeecms/img/login/ltop.jpg" /></td>
              </tr>
              <tr>
                <td><img src="${base}/res/jeecms/img/login/llogo.jpg" /></td>
              </tr>
            </table></td>
          <td width="40" align="center" valign="bottom"><img src="${base}/res/jeecms/img/login/line.jpg" width="23" height="232" /></td>
          <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="90" align="center" valign="bottom"><img src="${base}/res/jeecms/img/login/ltitle.jpg" /></td>
              </tr>
              <tr>
                <td>
                <div>
<#if errors??>
	<ul>
	<#list errors as error><li>${error}</li></#list>
	</ul>
</#if>
                </div>
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="5">
                    <tr>
                      <td width="91" height="40" align="right"><strong> <@s.m "login.username"/>：</strong></td>
                      <td width="211"><input type="input" id="username" name="username" vld="{required:true}" maxlength="100" class="input"/></td>
                    </tr>

                    <tr>
                      <td height="40" align="right"><strong><@s.m "login.password"/>：</strong></td>

                      <td id="pw">
                        <input name="password" type="password"id="password" maxlength="32" vld="{required:true}" class="input"/>
                      </td>
                    </tr>

                    <tr>
                      <td height="40" align="right"><strong><@s.m "login.dynamicPassword"/>：</strong></td>
                      <td><input name="dynamicPassword" type="input" id="dynamicPassword" maxlength="32" class="input"/>
                        <input id="btnCode"  type="button" value="动态口令"/>
                      </td>
                    </tr>

                    <#if errorRemaining?? && errorRemaining<=0>
                    <tr>
                    	<td colspan="2" align="center"><img src="${base}/captcha.svl" onclick="this.src='${base}/captcha.svl?d='+new Date()*1"/></td>
                    </tr>
                    <tr>
                      <td height="40" align="right"><strong><@s.m "login.captcha"/>：</strong></td>
                      <td><input name="captcha" type="text" id="captcha" vld="{required:true}" class="input"/></td>
                    </tr>
                    </#if>
                    <tr>
                      <td height="40" colspan="2" align="center">
 					              <button type="button" onclick="login()">登录</button>
                        &nbsp; &nbsp;
                        <button type="button" onclick="document.forms[0].reset()">重置</button>
                      </td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</form>
<input type="hidden" id="modouls" value="${modouls}">
<input type="hidden" id="exponent" value="${exponent}">
<#include "/common/alert_message.html"/>
</body>
</html>
